<!--{__NOLAYOUT__}-->
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="__STATIC__/js/layui/css/layui.css">
</head>
<body>
<div style="margin: 20px; ">
    <form class="layui-form layui-form-pane" id="Publish" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">文章标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" value="{$title}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章分类</label>
            <div class="layui-input-block">
                <select name="sort" lay-verify="required">
                    <option value=""></option>

                    {volist name="sortlist" id="vo"}

                    {if condition="$sort==$vo.sortid"}
                    <option value="{$vo.sortid}" selected>{$vo.sortname}</option>
                    {else /}
                    <option value="{$vo.sortid}">{$vo.sortname}</option>
                    {/if}

                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文章内容</label>
            <div class="layui-input-block">
                <textarea name="content" lay-verify="required" placeholder="请输入内容" class="layui-textarea">{$content}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="publishSubmit">确认修改</button>
            </div>
        </div>
    </form>
</div>

<input type="hidden" name="name" value="lalal">
<input type="hidden" name="articid" value="{$articid}">
<script src="__STATIC__/js/layui/layui.js" charset="utf-8"></script>


<script>
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    layui.use('form', function(){
        var form = layui.form;
        var $ = layui.$;
        //监听提交
        form.on('submit(publishSubmit)', function(data){
            var postdata = data.field;
            $.ajax({
                type: 'post'
                , dataType: 'json'
                , url: '/admin/article/edit?articid='+{$articid}
                , data: postdata
                , success: function (obj) {
                    if (obj.code === -1) {
                        layer.msg(obj.msg);
                    } else if (obj.code === 1) {
                        layer.msg(obj.msg);
                        parent.layer.close(index);

                    }

                }
            });
            return false;
        });
    });
</script>
</body>
</html>